package com.xh.xyzp.domain.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.xh.xyzp.util.AssertUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.Objects;

/**
 * @Author: xianghao
 * @Description:
 * @Date: 2025-04-12  11:11
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {
    private Long id;
    private String username;
    @JsonIgnore
    private String password;
    private String nickname;
    private String introduce;
    private String avatar;
    private Integer type; // 1.普通用户 2.公司 3.管理员
    private LocalDateTime createTime;
    private LocalDateTime updateTime;
    private Integer status;


    public User(Long id, String username, String password, String nickname, String introduce, String avatar, Integer type) {
        this.id = id;
        this.username = username;
        this.password = password;
        this.nickname = nickname;
        this.introduce = introduce;
        this.avatar = avatar;
        this.type = type;
    }

    public void checkParams() {
        if (Objects.nonNull(status)) {
            return;
        }
        AssertUtil.isNotEmpty(username, "账号不能为空");
        AssertUtil.isNotEmpty(nickname, "昵称不能为空");
        AssertUtil.isNotEmpty(introduce, "介绍不能为空");
    }
}
